<template>
    <div class="setting-uv-chart">
    </div>
</template>
<script>
import * as echarts from 'echarts'
export default {
    props: ['x', 'data'],
    computed: {
        option() {
            return {
                title: {
                    text: '访问统计',
                    left: 'center'
                },
                xAxis: {
                    type: 'category',
                    data: this.x
                },
                yAxis: {
                    type: 'value'
                },
                series: [
                    {
                        data: this.data,
                        type: 'line',
                        smooth: true
                    }
                ],
                tooltip: {
                    trigger: 'axis',
                    formatter: function (params) {
                        params = params[0];
                        console.log(params)
                        return params.name+":"+params.value
                    },
                    axisPointer: {
                        animation: false
                    }
                },
            }
        }
    },
    created() {
    },
    mounted() {
        this.initChart()
    },
    updated() {
        this.initChart()
    },
    methods: {
        initChart() {
            this.$nextTick(() => {
                echarts.init(this.$el).setOption(this.option)
            });
        }
    }
}
</script>
<style lang="scss">
.setting-uv-chart {
    height: 600px;
    width: 100%;
}
</style>